﻿#region File Header
//-----------------------------------------------------------------------------
// SibLib
//
// Copyright (C) 2010 Julien Villers
// This program is distributed under the terms of the 
// GNU Lesser General Public License (LGPL).
// See Docs/lgpl.txt and Docs/gpl.txt
//-----------------------------------------------------------------------------
#endregion

using Microsoft.Xna.Framework;

namespace SibLib.Entities
{
    /// <summary>
    /// Abstract base class for gameplay objects.
    /// </summary>
    public abstract class GameplayObject
    {
        #region Properties
        public Vector2 Position
        {
            get { return m_Position; }
            set { m_Position = value; }
        }
        public bool IsActive
        {
            get;
            set;
        }
        /// <summary>
        /// Rotation, in radians.
        /// </summary>
        public float Rotation
        {
            get { return m_Rotation; }
            set { m_Rotation = value; }
        }
        #endregion

        #region Protected Members
        protected bool m_IsInitialized;
        protected Vector2 m_Position;
        protected float m_Rotation;
        #endregion

        #region Construction

        protected GameplayObject()
        {
            m_IsInitialized = false;
        }

        #endregion

        #region Setup

        /// <summary>
        /// Default implementation checks m_IsInitialized, calls LoadContent, sets m_IsInitialized.
        /// </summary>
        public virtual void Initialize()
        {
            if (m_IsInitialized)
                return;

            LoadContent();

            m_IsInitialized = true;
        }

        /// <summary>
        /// Empty implementation provided.
        /// </summary>
        protected virtual void LoadContent()
        {

        }

        #endregion

        /// <summary>
        /// Called each frame to update object.
        /// </summary>
        /// <param name="timeFactor">Time elapsed since previous frame. Games can give it the meaning they want (seconds, milliseconds, etc)</param>
        public abstract void Update(float timeFactor);

        /// <summary>
        /// Called each frame to render object.
        /// </summary>
        /// <param name="timeFactor">Time elapsed since previous frame. Games can give it the meaning they want (seconds, milliseconds, etc)</param>
        public abstract void Draw(float timeFactor);
    }
}
